package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.CategoryService;
import com.atguigu.spzx.model.entity.product.Category;
import com.atguigu.spzx.model.vo.common.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author LT
 * @create 2024-03-15-21:30
 */
@RestController
@Tag(name = "商品管理模块")
@RequestMapping("/admin/product/category")
public class CategoryController {

    @Resource
    CategoryService categoryService;

    @GetMapping("listByPid/{pid}")
    public Result listByPid (@PathVariable("pid") Long pid) {
        List<Category> categoryList = categoryService.listByPid(pid);
        return Result.ok(categoryList);
    }

    @PostMapping("/export")
    public void exportCates(HttpServletResponse response){
        categoryService.exportCates(response);
    }

    @PostMapping("/import")
    public Result importCates(MultipartFile file){
        categoryService.importCates(file);
        return Result.ok();
    }





}
